<?php

namespace App\Service\Wanggui\Import;

use App\Models\OpenShop\Common\MallSettleInShopInfoModel;
use App\Models\OpenShop\Common\SiteLocationMallModel;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;

class FloorData
{
    public function collection(Collection $collection, ?Command $command)
    {
        $num = 0;
        $collection->first()->map(function ($store) use (&$num) {
            if ($num == 0) {
                $num++;
                return;
            }
            $data[] = [
                'mallId'         => $store[0] ?: '',
                'mallName'       => $store[1] ?: '',
                'province'       => $store[16] ?: '',
                'city'           => $store[17] ?: '',
                'address'        => $store[18] ?: '',
                'lng'            => $store[19] ?: '',
                'lat'            => $store[20] ?: '',
                'storeId'        => $store[2] ?: '',
                'storeName'      => $store[3] ?: '',
                'branchStore'    => $store[4] ?: '',
                'firstType'      => $store[5] ?: '',
                'secondType'     => $store[6] ?: '',
                'floor'          => $store[7] ?: '',
                'businessCircle' => $store[8] ?: '',
                'price'          => str_replace('/人', '', str_replace('消费:', '', ($store[9] ?: ''))),
                'score'          => $store[10] ?: '',
                'star'           => $store[11] ?: 0,
                'phone'          => $store[12] ?: '',
                'commentCount'   => $store[13] ?: 0,
                'status'         => $store[14] ?: 0,
                'statusText'     => $store[15] ?: '',
                'createdAt'      => time(),
                'updatedAt'      => time(),
            ];
            MallSettleInShopInfoModel::query()->insert($data);
            dump($num);
            $num++;
        });
    }
}
